/*
 * Template.java
 *
 * Created on 19 aprile 2004, 22.21
 */

package net.ermannofranco.xml.style;

import net.ermannofranco.xml.Tag;

/**
 * 
 * @author ermanno (ermanno.franco@gmail.com)
 */
public class Template extends StyleTag {

	private static final long serialVersionUID = -5115740426722292274L;

	/**
	 * Creates a new instance of Template Protetto
	 * 
	 * @param level
	 *            contatore di livello per indentazione, gestito automaticamente
	 * @param container
	 *            tag contenitore, automatico
	 */
	protected Template(int level, Tag container) {
		super("template", level, container);
	}

	/**
	 * @param xPathExpr
	 * @return autoref
	 */
	public Template setMatch(String xPathExpr) {
		addAttr("match", xPathExpr);
		return this;
	}

	/**
	 * @param name
	 * @return
	 */
	public Attribute addAttribute(String name) {
		Attribute t;
		add(t = new Attribute(getLevel() + 1, this).setName(name));
		return t;
	}

	/**
	 * @param name
	 * @return
	 */
	public Element addElement(String name) {
		Element t;
		add(t = new Element(getLevel() + 1, this).setName(name));
		return t;
	}

	/**
	 * @return
	 */
	public Choose addChoose() {
		Choose t;
		add(t = new Choose(getLevel() + 1, this));
		return t;
	}

	/**
	 * @param test
	 * @return
	 */
	public If addIf(String test) {
		If t;
		add(t = new If(getLevel() + 1, this).setTest(test));
		return t;
	}

	/**
	 * @param select
	 * @return
	 */
	public ForEach addForEach(String select) {
		ForEach t;
		add(t = new ForEach(getLevel() + 1, this).setSelect(select));
		return t;
	}

	/**
	 * @return
	 */
	public ApplyTemplates addApplyTemplates() {
		ApplyTemplates t;
		add(t = new ApplyTemplates(getLevel() + 1, this));
		return t;
	}

	/**
	 * @param select
	 * @return
	 */
	public ApplyTemplates addApplyTemplates(String select) {
		return addApplyTemplates().setSelect(select);
	}

}
